<?php
/**
 *  +----------------------------------------------------------------------
 *  | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 *  +----------------------------------------------------------------------
 *  | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
 *  +----------------------------------------------------------------------
 *  | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 *  +----------------------------------------------------------------------
 *  | Author: CRMEB Team <admin@crmeb.com>
 *  +----------------------------------------------------------------------
 */

/**
 * 帖子评论
 * @author crud自动生成代码
 * @date 2025/07/12 09:50:35
 */

namespace app\model\crud;


use crmeb\basic\BaseModel;

/**
 * Class PostsComment
 * @date 2025/07/12
 * @package app\model\crud
 */
class PostsComment extends BaseModel
{

    /**
     * 表名
     * @var string
     */
    protected $name = 'posts_comment';

    /**
     * 主键
     * @var string
     */
    protected $pk = 'id';


    /**
     * 评论人id一对一关联
     * @date 2025/07/12
     * @return \think\model\relation\HasOne
     */
    public function userIdHasOne()
    {
        return $this->hasOne(\app\model\user\User::class, 'uid', 'user_id')->field('uid,nickname as user_name,avatar');
    }

    /**
     * 帖子id一对一关联
     * @date 2025/07/12
     * @return \think\model\relation\HasOne
     */
    public function postsIdHasOne()
    {
        return $this->hasOne(\app\model\posts\Posts::class, 'id', 'posts_id')->field('id,title');
    }

}
